/*package com.pineapple.module.util.connection;

import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import util.type.DatabaseType.DbType;

import com.somapait.pwo.core.domain.BeanParameter;


public class DateUtil {
	public static String getCurrentDateDBDisplay(Connection conn,DbType dbType) {
		String currentDate = "";
		try{
			currentDate = util.date.DateUtil.getCurrentDateDB(conn, BeanParameter.getDateFormat4Display(), dbType);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return currentDate;
	}

	public static String getCurrentDateDBInsertUpdate(Connection conn,DbType dbType) throws Exception{
		String currentDate = "";
		try{
			currentDate = util.date.DateUtil.getCurrentDateDB(conn, BeanParameter.getDateFormat4InserUpdate(), dbType);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return currentDate;
	}


	*//**
	 * @param  05/02/2012 00:00:00
	 * �?ี �?.ศ. เ�?�?�? �?.ศ.   05/02/2555 00:00:00**//*

	public static String dateLocaleTh (String date){
		String dateReturn ="";
		if(date != null && !date.equals("")){
			String m = date.substring(0,6);
			String h = date.substring(11,date.length());

			String s  = date.substring(6,10);
			Integer y = Integer.parseInt(s)+543;

		    dateReturn = (m+y+" "+h);

		}
		return dateReturn;


	}

	public static String convertToString(Date date, String format,Locale locale) {
		if (date != null) {
			SimpleDateFormat formatDate = new SimpleDateFormat(format.toString(), locale);

			StringBuilder fdate = new StringBuilder(formatDate.format(date));
			return fdate.toString();
		} else {
			return "";
		}
	}

	//<dateFormat4Display>dd/MM/yyyy HH:mm:ss</dateFormat4Display> <dateFormatDisplay>dd/MM/yyyy</dateFormatDisplay>

	*//**
	 * @description : Date for show
	 * @param : Date
	 * *//*
	public static String dateForShow(Date date){
		String returnValue = null;
		try {
			if(date != null){

				returnValue = DateUtil.convertToString(date,BeanParameter.getDateFormatDisplay() , new Locale("th", "TH"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for Update Insert format DD/MM/YYYY HH24:MI:SS
	 * @param : String
	 * *//*

	public static String dateForInsert(String date){
		String returnValue = null;
		SimpleDateFormat sdf = new SimpleDateFormat(BeanParameter.getDateFormatDisplay(), new Locale("th", "TH"));
		try {
			if(date != null && !date.trim().equals("")){
				returnValue = DateUtil.convertToString(sdf.parse(date),BeanParameter.getDateFormat4Display() , Locale.ENGLISH);
				returnValue = "TO_DATE('" + returnValue + "','" + BeanParameter.getDateFormat4InserUpdate() + "')";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for Update Insert format DD/MM/YYYY HH24:MI:SS
	 * @param : String format dd/MM/yyyy HH:mm:ss
	 * *//*
	public static String dateForInsertWithTime(String date){
		String returnValue = null;
		SimpleDateFormat sdf = new SimpleDateFormat(BeanParameter.getDateFormat4Display(), new Locale("th", "TH"));
		try {
			if(date != null && !date.trim().equals("")){
				returnValue = DateUtil.convertToString(sdf.parse(date),BeanParameter.getDateFormat4Display() , Locale.ENGLISH);
				returnValue = "TO_DATE('" + returnValue + "','" + BeanParameter.getDateFormat4InserUpdate() + "')";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for Update Insert format dd/MM/yyyy
	 * @param String
	 * @return
	 *//*
	public static String dateForInsertNoTime(String date){
		String returnValue = null;
		SimpleDateFormat sdf = new SimpleDateFormat(BeanParameter.getDateFormatDisplay(), new Locale("th", "TH"));
		try {
			if(date != null && !date.trim().equals("")){
				returnValue = DateUtil.convertToString(sdf.parse(date),BeanParameter.getDateFormatDisplay() , Locale.ENGLISH);
				returnValue = "TO_DATE('" + returnValue + "','" + BeanParameter.getDateFormatDisplay() + "')";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for Update Insert format dd/MM/yyyy
	 * @param : String
	 * *//*
	public static String dateForInsertDDMMYYYY(String date){
		String returnValue = null;
		SimpleDateFormat sdf = new SimpleDateFormat(BeanParameter.getDateFormatDisplay(), new Locale("th", "TH"));
		try {
			if(date != null && !date.trim().equals("")){
				returnValue = DateUtil.convertToString(sdf.parse(date),BeanParameter.getDateFormatDisplay() , Locale.ENGLISH);
				returnValue = "TO_DATE('" + returnValue + "','" + BeanParameter.getDateFormatDisplay() + "')";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for Update Insert
	 * @param : String
	 * @return : yyyyMMdd ,yyyyMMddHHmmss (by format)
	 * *//*
	public static String dateForInsert(String date, String format) {
		String returnValue = null;
		SimpleDateFormat sdf = new SimpleDateFormat(BeanParameter.getDateFormatDisplay(), new Locale("th", "TH"));
		try {
			if (date != null && !date.equals("")) {
				returnValue = DateUtil.convertToString(sdf.parse(date),format , Locale.ENGLISH);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for show
	 * @param : String ,format ,local
	 *
	 * *//*

	public static String convertToString(String date, String format,Locale lc) {
		if(date==null) return null;
		String output = "";
		 input 20090101235959 yyyymmddhh24miss
		if (date.length() >= 8) {
			Calendar c = Calendar.getInstance(lc);
			int year = Integer.parseInt(date.substring(0, 4));
			int month = Integer.parseInt(date.substring(4, 6));
			int d = Integer.parseInt(date.substring(6, 8));
			c.set(year, month, d);
			c = Calendar.getInstance(lc);
			String fmtYear = String.valueOf(c.get(Calendar.YEAR));
			date=date.trim();
			if (format.toString().equalsIgnoreCase("YYYYMMDDHH24MISS")) {
				output = fmtYear + date.substring(4, 13);

			}
			if (format.toString().equalsIgnoreCase("YYYYMMDD")) {
				if (date.length() < 10) {
					return output;
				} else {
					output = fmtYear + date.substring(4, 8);
				}

			}
			if (format.toString().equalsIgnoreCase("HH24MISS")) {
				if (date.length() < 10) {
					return output;
				} else {
					output = date.substring(8, 10) + date.substring(10, 12)
							+ date.substring(12, 14);
				}

			}

			if (format.toString().equalsIgnoreCase("dd/MM/yyyy")) {
				if (date.length() < 8) {
					return output;
				} else {
//					output = date.substring(4, 6)
//							+ "/"
//							+ date.substring(6, 8)
//							+ "/"
//							+ fmtYear;
					output = date.substring(6, 8)
					+ "/"
					+ date.substring(4, 6)
					+ "/"
					+ fmtYear;
				}

			}

			if (format.toString().equalsIgnoreCase("dd-MM-yyyy")) {
				if (date.length() < 8) {
					return output;
				} else {
					output = date.substring(4, 6)
							+ "-"
							+ date.substring(6, 8)
							+ "-"
							+ fmtYear;
				}

			}
			if (format.toString().equalsIgnoreCase("MM-dd-yyyy")) {
				if (date.length() < 8) {
					return output;
				} else {
					output =  date.substring(6, 8)+ "-"+
							date.substring(4, 6)
							+ "-"
							+ fmtYear;
				}

			}
			if (format.toString().equalsIgnoreCase("MM/dd/yyyy")) {
				if (date.length() < 8) {
					return output;
				} else {
					output =  date.substring(6, 8)+ "/"+
							date.substring(4, 6)
							+ "/"
							+ fmtYear;
				}

			}

			if (format.toString().equalsIgnoreCase("yyyy-MM-dd")) {
				if (date.length() < 8) {
					return output;
				} else {
					output =  fmtYear+"-"+date.substring(6, 8)+ "-"+
							date.substring(4, 6);
				}

			}
			if (format.toString().equalsIgnoreCase("yyyy/MM/dd")) {
				if (date.length() < 8) {
					return output;
				} else {
					output =  fmtYear+"/"+date.substring(6, 8)+ "/"+
							date.substring(4, 6);
				}

			}
			if (format.toString().equalsIgnoreCase("dd/MM/yyyy HH:mm:ss")) {
				if (date.length() < 19) {
					if (date.length() == 14) {
						// input 20090101235959
						output = date.substring(6, 8) + "/"
								+ date.substring(4, 6) + "/"
								+ fmtYear + " "
								+ date.substring(8, 10) + ":"
								+ date.substring(10, 12) + ":"
								+ date.substring(12, 14);
					}
					return output;
				} else {
					output = date.substring(6, 8)
							+ "/"
							+ date.substring(4, 6)
							+ "/"
							+fmtYear + " " + date.substring(9, 11)
							+ ":" + date.substring(12, 14) + ":"
							+ date.substring(15, 17);
					return output;
				}

			}

			//Santi.k 2011-11-08
			if (format.toString().equalsIgnoreCase("dd/MM/yyyy HH:mm")) {
				if (date.length() < 19) {
					if (date.length() == 14) {
						output = date.substring(6, 8) + "/"
								+ date.substring(4, 6) + "/"
								+ fmtYear + " "
								+ date.substring(8, 10) + ":"
								+ date.substring(10, 12) ;
					}
					return output;
				} else {
					output = date.substring(6, 8)
							+ "/"
							+ date.substring(4, 6)
							+ "/"
							+fmtYear + " " + date.substring(9, 11)
							+ ":" + date.substring(12, 14);
					return output;
				}

			}
			//Santi.k 2011-11-08
			if (format.toString().equalsIgnoreCase("dd/MM/yy HH:mm")) {
				if (date.length() < 19) {
					if (date.length() == 14) {
						output = date.substring(6, 8) + "/"
						+ date.substring(4, 6) + "/"
						+ fmtYear.substring(2,4) + " "
						+ date.substring(8, 10) + ":"
						+ date.substring(10, 12) ;
					}
					return output;
				} else {
					output = date.substring(6, 8)
					+ "/"
					+ date.substring(4, 6)
					+ "/"
					+ fmtYear.substring(2,4) + " " + date.substring(9, 11)
					+ ":" + date.substring(12, 14);
					return output;
				}

			}
		} else {

			output = date;
		}
		return output;
	}

	*//**
	 * @description : Date for show YYYYMMddHHmmss Locale EN
	 * @param : Date
	 * *//*
	public static String dateyyyyMMddHHmmssEN(Date date){
		String returnValue = null;
		try {
			if(date != null){

				returnValue = DateUtil.convertToString(date,"yyyyMMddHHmmss" , new Locale("en", "EN"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Date for show YYYYMMdd Locale EN
	 * @param : Date
	 * *//*
	public static String dateyyyyMMddEN(Date date){
		String returnValue = null;
		try {
			if(date != null){
				returnValue = DateUtil.convertToString(date,"yyyyMMdd" , new Locale("en", "EN"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnValue;
	}

	*//**
	 * @description : Convert Date string from dd/MM/yyyy to yyyyMMdd Locale TH
	 * @param : Date
	 * *//*
	public static String dateyyyyMMddTH(String date){
		String returnValue = null;
		try {
			if(date != null){
				SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy", new Locale("th", "TH"));
				Date d = sdf.parse(date);
				returnValue = DateUtil.convertToString(d,"yyyyMMdd" , new Locale("th", "TH"));
			}
		} catch (Exception e) {
			e.printStackTrace();
			returnValue = date;
		}
		return returnValue;
	}

	*//**
	 * @description : Convert Date string from formatIn Locale EN to formatOut Locale TH
	 * @param : Date
	 * *//*
	public static String dateFormatInOutENToTH(String date,String formatIn,String formatOut){
		String returnValue = null;
		try {
			if(date != null){
				SimpleDateFormat sdf = new SimpleDateFormat(formatIn, new Locale("en", "EN"));
				Date d = sdf.parse(date);
				returnValue = DateUtil.convertToString(d,formatOut , new Locale("th", "TH"));
			}
		} catch (Exception e) {
			e.printStackTrace();
			returnValue = date;
		}
		return returnValue;
	}

}
*/